package com.shujia.flink.source

import org.apache.flink.streaming.api.scala._

object Demo1ListSource {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    /**
      * 1、基于本地集合构建DataStream  --- 有界流
      *
      */


    val list = List("java,spark", "java,hadoop,spark", "hadoop")

    val listDS: DataStream[String] = env.fromCollection(list)


    listDS
      .flatMap(_.split(","))
      .map((_, 1))
      .keyBy(_._1)
      .sum(1) //下标从0开始
      .print()


    env.execute()

  }

}
